package hashTable;

public class MyHashTable<T> {
    private static final int SIZE= 16;
    MyLinkedList<T>[] table;
    public MyHashTable() {
        table = new MyLinkedList[SIZE];
    }
    public void add(String id, T element){
        int index = getIndex(id);
        if(table[index]==null){
            table[index] = new MyLinkedList<T>();
        }
        table[index].add(id,element);
    }
    public int delete(String id){
        int index = getIndex(id);
        if(table[index]==null){
            return 0;
        }
        return  table[index].delete(id);
    }
    public T search(String id){
        int index = getIndex(id);
        if(table[index]==null){
            return null;
        }
        return  table[index].search(id);
    }
    private int getIndex(String id){
        return id.hashCode()%SIZE;
    }
}
